#include "monitor.h"
#include "descriptor_tables.h"
#include "timer.h"
#include "paging.h"
#include "multiboot.h"
#include "task.h"
#include "syscall.h"
#include "convert_kbd.h"

extern u32int placement_address;
u32int initial_esp;

void kmain( void* mbd, unsigned int magic, u32int initial_stack )
{
  initial_esp = initial_stack;
  // Initialise all the ISRs and segmentation
  init_descriptor_tables();
  // Initialise the screen (by clearing it)
  monitor_clear();
  monitor_write("  ___               \n");
  monitor_write(" |    \\ /  \\    /   \n");
  monitor_write(" |__   |     \\/     \n");
  monitor_write("    |  |    /  \\    \n");
  monitor_write("  __|  |  /      \\  \n");
  // Initialise the PIT to 100Hz
  monitor_write("Initializing a 100Hz timer...\n");
  init_timer(50);
  monitor_write("Remapping the PIC...\n");
  PIC_remap(0x08,0x70);
  monitor_write("Starting multi-tasking mode...\n");
  initialise_tasking();
  monitor_write("Testing mouse...\n");
  mouse_install();
}
